package router

import (
	"blog/app/controllers"
	"github.com/kataras/iris/core/router"
)

func SetRouter(p router.Party) {

	var (
		configController  = &controllers.ConfigController{}
		articleController = &controllers.ArticleController{}
		tagController = &controllers.TagController{}
	)

	api := p.Party("/")

	api.Get("/config", configController.GetHandler)


	api.Get("/login", configController.LoginHandler)

	api.Get("/articles/{id:uint64}",articleController.GetHandler)
	api.Get("/articles", articleController.QueryHandler)

	api.Get("/createdate_stat", articleController.GetCreatedateStatHandler)

	api.Get("/tag_stat",tagController.GetStatHandler)

	admin := api.Party("/admin")
	//admin := api.Party("/admin",middlewares.PermissionHandlerFunc())

	api.Get("/articles/{id:uint64}",articleController.GetAdminHandler)
	admin.Post("/article",articleController.InsertHandler)
	admin.Put("/articles/{id:uint64}",articleController.UpdateHandler)
	admin.Delete("/articles/{id:uint64}",articleController.DeleteHandler)

	api.Put("/config", configController.UpdateHandler)

	admin.Get("/tags",tagController.GetHandler)
	admin.Post("/tag",tagController.InsertHandler)
	admin.Put("/tags/{id:uint}",tagController.UpdateHandler)
	admin.Delete("/tags/{id:uint}",tagController.DeleteHandler)


}
